﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Workbench.Presentation
{
    /// <summary>
    /// Interaction logic for PromptDialog.xaml
    /// </summary>
    public partial class PromptDialog : Window
    {
        public PromptDialog()
        {
            InitializeComponent();
        }

        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            Close();
        }

        public static string Prompt(string question, string title, string defaultValue = "")
        {
            return Prompt(null, question, title, defaultValue);
        }
        public static string Prompt(Window owner, string question, string title, string defaultValue = "")
        {
            PromptDialog inst = new PromptDialog();
            inst.lblQuestion.Content = question;
            inst.Title = title;
            inst.tbQuestion.Text = defaultValue;
            inst.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            inst.Owner = owner;
            inst.ShowDialog();
            if (inst.DialogResult == true)
                return inst.tbQuestion.Text;
            return null;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            tbQuestion.Focus();
        }
    }
}
